<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <script type="text/javascript" >
        function reply(id)
        {
            document.getElementById('id_parent_message').value=id
            document.getElementById('id_content').value = 'Re:\n'
        }
    </script>
    <body>
        {{total_page}}
        {{current_page}}
        <div class="add_message_container">
            <form action="add_message" method="post">
                <table>
                    {{form}}
                </table>

                <input type="submit" value ="submit"/>
            </form>
        </div>
        <div class="pagination">

            {% if messages.has_previous %}
            <span class="previous_next_page">
                <a href="?page={{ messages.previous_page_number }}">previous</a>
            </span>
            {% endif %}

            <span class="current_page_number">
                Page {{ messages.number }} of {{ messages.paginator.num_pages }}
            </span>

            {% if messages.has_next %}
            <span class="previous_next_page">
                <a href="?page={{ messages.next_page_number }}">next</a>
            </span>
            {% endif %}


        </div>
        <div class="messages_container">

            <ul>
                {% for message in messages.object_list %}
                <li>
                    <div class="message_container">
                        <div class="message_id">
                            {{message.id}}
                            {% if message.parent_message%}
                            Re:{{message.parent_message.id}}
                            {% endif %}
                        </div>
                        
                        <span class="message_time">
                            {{message.time}}
                        </span>
                        <span class="message_author">
                            {{message.author}} says:
                        </span>
                        
                        <div class="message_content">
                            {{message.content}}
                        </div>
                        <div class="message_reply">
                            <a href="#" onclick="reply({{message.id}})">reply</a>
                        </div>
                    </div>
                </li>
                {% endfor %}
            </ul>
        </div>
    </body>
</html>
